Skip to content

Conversation

@nedbat
Copy link
Member

@nedbat nedbat commented Dec 27, 2025

In fact, I think everywhere TraceFunction is used, it can be None, but I have no experience with bdb.

Should we change the definition and simplify the uses of the alias?:

# Objects suitable to be passed to sys.settrace, threading.settrace, and similar
TraceFunction: TypeAlias = Callable[[FrameType, str, Any], TraceFunction | None] | None

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I personally prefer None not to be part of type aliases like this, because it isn't really a trace function, but a value with special meaning. And I like that the parameter definition says "x or None" explicitly. But that's just my personal opinion, not typeshed policy.

@srittau srittau merged commit 6b4691d into python:main Dec 27, 2025
63 checks passed
@nedbat
Copy link
Member Author

nedbat commented Dec 27, 2025

But that's just my personal opinion, not typeshed policy.

Is there a typeshed policy that we shouldn't add | None to the type alias? I'll make a PR to simplify all the uses if we can.

@nedbat nedbat deleted the nedbat/threading-settrace branch December 27, 2025 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants